package com.yyn.seckill.controller;


import com.yyn.seckill.entity.dto.GoodDetialListDto;
import com.yyn.seckill.entity.dto.GoodListDto;
import com.yyn.seckill.service.GoodsService;
import com.yyn.seckill.vo.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author yyn
 * @since 2023-01-21
 */
@RestController
@RequestMapping("/seckill/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @ApiOperation("商品秒杀列表")
@GetMapping("/goodList")
    public R goodList(){
    List<GoodListDto> goodListDtos = goodsService.goodList();
   return R.success().data("goodsList",goodListDtos);
}
    @ApiOperation("商品秒杀详情")
    @GetMapping("/goodDetialList/{goodId}")
    public R goodDetialList(@PathVariable String goodId){
        GoodDetialListDto goodDetialList = goodsService.goodDetialList(goodId);
        return R.success().data("goodDetialList",goodDetialList);
    }

    @ApiOperation("倒计时功能")
    @GetMapping("goodsSkill/{goodsId}")
    public R goodsSkill(@PathVariable String goodsId){
        Map map = goodsService.goodsSkill(goodsId);
        return R.success().data(map);
    }
}

